package org.jetlinks.community.mstn.web;

import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.hswebframework.web.authorization.annotation.Authorize;
import org.hswebframework.web.authorization.annotation.Resource;
import org.jetlinks.community.mstn.entity.AssetPermission;
import org.jetlinks.community.mstn.enums.AssetsType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * 资产管理
 *
 */
@RestController
@RequestMapping("/asset")
@Authorize
@Resource(id = "asset", name = "资产类型", group = "mstn")
@Tag(name = "资产类型")
@AllArgsConstructor
public class AssetController {

    @GetMapping("/types")
    public Flux<AssetPermission> types(){
        ArrayList<AssetPermission> assetPermissions = new ArrayList<>();
        for (AssetsType assetsType: AssetsType.values()){
            AssetPermission permission = new AssetPermission();
            permission.setId(assetsType.getValue());
            permission.setName(assetsType.getText());
            assetPermissions.add(permission);
        }
        return Flux.fromIterable(assetPermissions);
    }
}
